﻿@using NewLife.Common;
@using NewLife.Model;
@using XCode.Membership;
@using NewLife.Cube;
@using XCode;
@using NewLife.Cube.ViewModels;

@{
    var menu = ViewBag.Menu as IMenu;

    var user = ViewBag.User as IUser ?? ManageProvider.User;
    var fact = ManageProvider.Menu;
    var menus = fact.Root.Childs;
    if (user?.Role != null)
    {
        menus = fact.GetMySubMenus(fact.Root.ID, user, true);
    }
}

<!-- 左侧菜单 -->
<div class="app-sidebar-menu overflow-hidden flex-column-fluid">
    <div id="kt_app_sidebar_menu_wrapper" class="app-sidebar-wrapper hover-scroll-overlay-y my-5" data-kt-scroll="true" data-kt-scroll-activate="true" data-kt-scroll-height="auto" data-kt-scroll-dependencies="#kt_app_sidebar_logo, #kt_app_sidebar_footer" data-kt-scroll-wrappers="#kt_app_sidebar_menu" data-kt-scroll-offset="5px" data-kt-scroll-save-state="true">
        <div class="menu menu-column menu-rounded menu-sub-indention px-3" id="#kt_app_sidebar_menu" data-kt-menu="true">
            <div class="menu-item">
                <a class="menu-link" href="@NewLife.Cube.Setting.Current.StartPage">
                    <span class="menu-icon">
                        <span class="fas fa-tv fs-3 text-gray-700"></span>
                    </span>
                    <span class="menu-title fs-4">系统首页</span>
                </a>
            </div>
            <div class="menu-item">
                <div class="menu-content">
                    <div class="separator mx-1"></div>
                </div>
            </div>

            @if (menu != null)
            {
                foreach (IMenu item in menus)
                {
                    if (item.ParentID == 0)
                    {
                        @await Html.PartialAsync("_Layout_Aside_MenuItem", new ValueTuple<IMenu, IMenu>(menu, item))
                    }
                }
            }
            <div class="menu-item">
                <div class="menu-content">
                    <div class="separator mx-1 my-4"></div>
                </div>
            </div>
            <div class="menu-item">
            </div>
        </div>
    </div>
</div>